package com.neusoft.SPNursingHome.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.neusoft.SPNursingHome.po.Bed;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface BedDao extends BaseMapper<Bed> {
    /**
     * 查询当前所有“空闲”状态的床，并返回它们对应的不重复房间号列表
     */
    @Select("SELECT DISTINCT room_id FROM bed WHERE bed_status = '空闲'")
    List<String> selectRoomsWithFreeBeds();

    /**
     * 根据房间号，查询该房间下所有状态为“空闲”的床
     */
    @Select("SELECT * FROM bed WHERE room_id = #{roomId} AND bed_status = '空闲'")
    List<Bed> selectFreeBedsByRoom(@Param("roomId") String roomId);

}